Developer Documentation
PATH  WebObjects 4.5 Documentation > Getting Started With Direct to Java Client

   

Generating the Select Studio Dialog

As an example of how the Direct to Java Client D2WComponent classes work, consider the select Studio dialog. Suppose a user clicks the Select button on a Movie form window to select a new Studio for the Movie. The controller factory then makes a request to the rule system with the following specification:

entity = Studio, question = modalDialog, task = select
The default rule fired to satisfy this request is:

Thus, the D2WComponent that generates the XML for the select Studio dialog is EOModalDialog. The EOModalDialog's .wo contains:

EOModalDialog.html (XML)

<WEBOBJECT name=modalDialogController>
    <WEBOBJECT name=actionWidgetController>
        <WEBOBJECT name=taskController/>
    </WEBOBJECT>
    <WEBOBJECT name=content/>
</WEBOBJECT>

EOModalDialog.wod

modalDialogController: EOSwitchComponent {
    componentNameKey = "modalDialogController";
    d2wContext = localContext;
    controllerType = "modalDialogController";
}
actionWidgetController: EOSwitchComponent {
    componentNameKey = "actionWidgetController";
    d2wContext = localContext;
    controllerType = "actionWidgetController";
    forceHorizontallyNotResizable = noValue;
    forceVerticallyNotResizable = noValue;
    isRootController = "false";
}
taskController: EOSwitchComponent {
    componentNameKey = "controller";
    d2wContext = localContext;
    controllerType = noValue;
    forceHorizontallyNotResizable = noValue;
    forceVerticallyNotResizable = noValue;
    isRootController = "false";
}
content: WOComponentContent {
}

The EOSwitchComponent you see in the .wod file is a private dynamic element that makes a new rule system request using the componentNameKey as the request key. So for example, consider the modalDialogController. The switch component makes a new rule system request with the key "modalDialogController" (the value of the componentNameKey binding).

Before making the request, however, the switch component updates the rule system's state information. Generally it creates a new D2WContext based on the state information in the old D2WContext. That's what the d2wContext binding specifies. The remaining bindings (any binding other than componentNameKey and d2wContext) identify additional state that the switch component adds to the new D2WContext. For the modalDialogController, the additional state is simply that the controllerType is "modalDialogController".

In this manner, the XML hierarchy is built recursively using switch components. One of the leaf nodes in the select Studio dialog is for an EOTextFieldController who's .wod file looks like this:

controller: WOXMLNode {
    elementName = "TEXTFIELDCONTROLLER";
    alignment = d2wContext.alignment;
    alignmentWidth = d2wContext.alignmentWidth;
    alignsComponents = d2wContext.alignsComponents;
    className = d2wContext.className;
    displayGroupProviderMethodName =
        d2wContext.displayGroupProviderMethodName;

    editability = d2wContext.editability;
    enabledDisplayGroupProviderMethodName =
        d2wContext.enabledDisplayGroupProviderMethodName;

    enabledKey = d2wContext.enabledKey;
    formatAllowed = d2wContext.formatAllowed;
    formatClass = d2wContext.formatClass;
    formatPattern = d2wContext.formatPattern;
    highlight = d2wContext.highlight;
    horizontallyResizable = d2wContext.horizontallyResizable;
    iconName = d2wContext.iconName;
    iconURL = d2wContext.iconURL;
    isQueryWidget = d2wContext.isQueryWidget;
    label = d2wContext.label;
    labelAlignment = d2wContext.labelAlignment;
    labelComponentPosition = d2wContext.labelComponentPosition;
    minimumHeight = d2wContext.minimumHeight;
    minimumWidth = d2wContext.minimumWidth;
    prefersIconOnly = d2wContext.prefersIconOnly;
    usesHorizontalLayout = d2wContext.usesHorizontalLayout;
    usesLabelComponent = d2wContext.usesLabelComponent;
    valueKey = d2wContext.propertyKey;
    verticallyResizable = d2wContext.verticallyResizable;
}
content: WOComponentContent {
}

A WOXMLNode is a component that generates XML for a node in the controller hierarchy. It's bindings tell the server side D2WComponent how to configure it's client side counterpart. For example, the binding names in the EOTextFieldController .wod file correspond to XML attributes understood by the client side EOTextFieldController. Correspondingly, the binding values are the values assigned to those XML attributes. Most of the bindings are set to a key path starting with "d2wContext". These key paths refer to the state information stored in the D2WContext.

For example, the client side EOTextFieldController uses the XML attribute usesLabelComponent to specify whether it should generate a label for its text field widget. The server side EOTextFieldController assigns a value to the usesLabelComponent XML attribute based on state stored in the rule system's D2WContext.


© 1999 Apple Computer, Inc. – (Draft. Last updated 05 Jan 00)